home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qlib205.zip / QLIB.ZIP / TXT / PACK.TXT < prev    next >
Text File  |  1997-02-10  |  4KB  |  77 lines

  1. packed file IO
  2. --------------
  3.   Pack file IO is a set of functions that allow you to copy all files
  4. for a project into one file.  This means all the grafix and sound files (or
  5. whatever) can be kept in one file and then accessed normally thru the
  6. standard IO functions (ie: open,close,read,etc.)
  7.   This massive packed files are created using a utility called PACKIT.
  8. To make a packed file just use PACKIT within a directory of files to pack.
  9. Give it a parameter of a file to output to.
  10.   EG:  packit ..\data.000
  11.   Then use the following functions to load in data.000 and the files within.
  12. PACKIT.C is included if you need the source.
  13.  
  14. pack_init,nooffiles:word,packs:word
  15.   - initalizes the system (alloc's ram and enabling sub-system)
  16.   - nooffiles specifies how many files can be loaded within all
  17.     the packed files which will be opened
  18.   - packs specifies how many packed files may be opened with the pack_open()
  19.     and pack_open_hdr() functions
  20.  
  21. pack_uninit
  22.   - frees buffers and disables the whole sub-system
  23.   - all files are closed!
  24.   - it is not necessary to call this during program exit
  25.  
  26. pack_open,filename:dword
  27.   - loads a packed file so that the files within can be opened
  28.   - returns a handle(word) that can be used with pack_close()
  29.  
  30. pack_open_hdr,filename:dword,hdr:dword
  31.   - loads a packed file so that the files within can be opened
  32.   - hdr must point to the header of the pack file which must already be
  33.     loaded into memory
  34.   - returns a handle(word) that can be used with pack_close()
  35.  
  36. pack_close,hand:dword
  37.   - closes a packed file making all files with the pack file no longer
  38.    accessable and frees the DOS file handle used with the pack file.
  39.  
  40. Packit also has a new option that will output the header to a different
  41. file which you can incorperate into your EXE file to protect the files
  42. within the pack file if you wish.  These new PACK files must be opened with
  43. pack_open_hdr() and you must have the header already in memory.
  44.  
  45.   Each pack file opened is kept open for the entire duration of the program
  46. so that means each pack file will need a file handle (so don't open too
  47. many file handles).   Most system have about 40 handles so opening more
  48. than 30 pack files would be too many.
  49.  
  50.   Once you've inited and opened data files just simply use open() to open the
  51. files within.  What happens is that if open() cannot find the file in any 
  52. packed file it then allows DOS to attempt to open the file as usually.
  53. If it does find it in a packed file , it returns the already open handle and lseeks the file to
  54. the begining of that file within the pack file.  If an attempt is made to close
  55. the file it is just ignored and returned successful.  This is very useful
  56. because you can use other routines such as 'g_loadfnt' with a file within
  57. a packed file and it will use it just like any other file.  One last note,
  58. the packed files are opened in read only mode with Pack_open.
  59. Pack_init() lets you set the limit of how many files within the pack files
  60. can be loaded and how many packed files can be opened when you call.  This can
  61. only be called once!
  62.  
  63. NOTE: Pack.asm keeps internal vars set to the current file opened and therefore
  64.   only one file can be opened at a time from with in the packed files.  The
  65.   actual handles for each packed file are kept open.  When anything tries
  66.   to open one of them pack.asm just returns the handle and lseeks the pack file
  67.   to the proper position.  Plus any lseek done on the file is handled properly.
  68.   If a file is contained in two or more packed files the most recently opened
  69.   pack file will be used instead.  This is good for adding patches to games
  70.   and other stuff. (like how DOOM adds wads which simply overides files)
  71.   If a file exists within a packed file and this file also exists in the
  72.   current directory then you will only be able to load the one in the
  73.   packed file, unless you have not called pack_init() and pack_open() yet.
  74.  
  75. Cool eh...?
  76.  
  77.